package com.creditservice;

import com.creditservice.types.CreditCard;

import javax.ejb.Stateless;
import javax.jws.WebService;

@WebService(name = "CreditService", serviceName = "CreditService")
@Stateless()
public class ValidateCreditCardImpl {

    public boolean verifyCC(CreditCard creditCard) throws CreditCardValidationFaultMessage {
        boolean validOrNot = false;
        if ((creditCard.getCcType().equals("AMEX")) || (creditCard.getCcType().equals("Visa"))) {
            validOrNot = true;
            Long ccnum = new Long(creditCard.getCcNum());
            if (ccnum < 12345678) {
                validOrNot = false;
            } else {
                validOrNot = true;
            }

        } else {
            validOrNot = false;
        }

        return validOrNot;
    }
}
